package com.fulihui.usercore.common.integration.impl;


import com.fulihui.systemcore.api.WechatTokenService;
import com.fulihui.systemcore.request.wechat.WechatTokenRequest;
import com.fulihui.systemcore.response.wechat.WechatTokenResult;
import com.fulihui.usercore.common.integration.WechatTokenServiceClient;
import org.apache.dubbo.config.annotation.Reference;
import org.near.servicesupport.util.ServiceResultUtil;
import org.springframework.stereotype.Component;

/**
 * @author Created by Willard.Hu on 2016/8/18.
 * @see WechatTokenServiceClient
 */
@Component
public class WechatTokenServiceClientImpl implements WechatTokenServiceClient {
    @Reference(version = "1.0.0", check = false)
    private WechatTokenService wechatTokenService;

    /**
     * @see WechatTokenServiceClient#getToken(WechatTokenRequest)
     */
    @Override
    public String getToken(WechatTokenRequest request) {
        WechatTokenResult result = wechatTokenService.getToken(request);
        ServiceResultUtil.checkResult(result);
        return result.getToken();
    }
}
